const express = require('express');

const app = express();

// 中间件的顺序很重要
// req 请求对象
// res 响应对象
// next 下一个中间件
app.use((req, res, next) => {
    console.log(req.method, req.url, Date.now());
    // 交出执行权，往后继续匹配执行
    next();
})

app.get('/', (req, res) => {
    res.send('get /');
});

app.get('/about', (req, res) => {
    res.send('get /about');
});

app.post('/login', (req, res) => {
    res.send('post /login');
});

app.listen(3000, () => {
    console.log(`Server running at http://localhost:3000/`);
})